package com.study.d3_method_reference;

import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        //理解静态方法的引用
        Student[] students = new Student[4];
        students[0]=new Student("一帆风顺",175,'男',20);
        students[1]=new Student("二话不说",165,'男',130);
        students[2]=new Student("三心二意",170,'女',220);
        students[3]=new Student("四面八方",185,'女',10);
//   1、     Arrays.sort(students, (o1, o2)-> o2.getAge()-o1.getAge());
         //静态方法的引用
        //类名::静态方法
        //使用场景：如果某个lambda表达式里只是调用一个静态方法，并且前后参数的形式一致，就可以使用静态方法引用
//   2、     Arrays.sort(students, (o1, o2)-> Student.compareByAge(o1,o2));
        Arrays.sort(students,Student::compareByAge);//3
        System.out.println(Arrays.toString(students));
    }
}
